# Contributor: Rasmus Thomsen <oss@cogitri.dev>
# Maintainer: Rasmus Thomsen <oss@cogitri.dev>
pkgname=apk-polkit-rs
pkgver=2.1.1
#_gitlabsha=d52c3da65fe202a9e97c3d228af952c6
_commit=6bc6b97206ae681ab4b675c7d782ef7985b7a7f4
# Revert once we can use releases again!
options="net"
pkgrel=1
pkgdesc="apk-polkit-rs exposes a DBus API for APK, the Alpine Package Keeper"
url="https://gitlab.alpinelinux.org/Cogitri/apk-polkit-rs"
arch="x86_64 armv7 armhf aarch64 x86 ppc64le riscv64"
license="GPL-3.0-or-later"
depends="polkit alpine-appstream-downloader"
makedepends="meson cargo polkit-dev glib-dev clang-dev apk-tools-dev"
checkdepends="appstream bash dbus py3-dbusmock"
subpackages="$pkgname-dev $pkgname-dbg $pkgname-lang $pkgname-openrc"
install="$pkgname.post-install $pkgname.post-upgrade"
source="$pkgname-$_commit.tar.gz::https://gitlab.alpinelinux.org/Cogitri/apk-polkit-rs/-/archive/$_commit.tar.gz
	apk-tools-2-14-compat.patch
	0001-fix-apk-tools-sys-fix-new-apk_package-structure.patch
	0003-feat-apk-tools-sys-remove-custom-binding-for-apk_pac.patch
	0004-chore-Cargo-update-dependencies.patch
	0005-chore-apk-tools-sys-update-bindgen.patch
"
builddir="$srcdir/$pkgname-$_commit"

prepare() {
	default_prepare

	sed '/CBUILD/d' -i meson.build
	cargo fetch --target="$CTARGET" --locked
}

build() {
	abuild-meson . output
	meson compile -C output
}

check() {
	dbus-run-session -- \
		meson test --no-rebuild --print-errorlogs -C output
}

package() {
	DESTDIR="$pkgdir" meson install --no-rebuild -C output
}

sha512sums="
75a27ba12b1ab804eca33074a1361f7c5b74e87d04b441f8378d1c2c6b830524118d55c859bbf64b18494c9fd5df000bfeda2e780f83431289511f57ac35d0b0  apk-polkit-rs-6bc6b97206ae681ab4b675c7d782ef7985b7a7f4.tar.gz
990b2dab6db4c44bb4f69382167420cb437395dde246de5a7d16e8e6f372764c745a15865256d9b49c2c436db449923079bf6b09f4c0bb76a5feb20002258bc4  apk-tools-2-14-compat.patch
fdb5b8a525955c770a98af524e3af7514614d44ab36c3ae0254d52014e7f94ec3878ccea18164e8a9ba7bdabac3e117006e70cb02114de3d20bbea4549d7c3b3  0001-fix-apk-tools-sys-fix-new-apk_package-structure.patch
b47eb5823326e903b0cc45507f03d12519389f169cb94d2afab663007773f82375f413faf5cc54df21aa0063e25d64e329bb77f1a3d8c9cd545c970a5b4b3347  0003-feat-apk-tools-sys-remove-custom-binding-for-apk_pac.patch
c7a13a0c13654b47a37af342f139e22367492dec7ba7fc934b75a88c7843e49a428d7753699b3af4d2d15515e29b5754683f482d7781624af2c3977178b27cc1  0004-chore-Cargo-update-dependencies.patch
d9c80226dd11c4e856d89006cf2225f5f7c71e0521caab2baca2e8a6ffc28f8ad991810eb5ba643732ca23691017a3a438c4517eac561471976c37ea9d722112  0005-chore-apk-tools-sys-update-bindgen.patch
"
